//
//  YWInspecEquipmentRecordDetailTableViewController.m
//  maintain
//
//  Created by Kyo on 16/8/4.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWInspecEquipmentRecordDetailTableViewController.h"
#import "UIColor+CustomColors.h"
#import "UIImageView+WebCache.h"
#import "YWCommonTool.h"
#import "YWMacro.h"
#import "YWConst.h"
#import "UILabel+AttributedText.h"
#import "YWBuilding.h"
#import "YWBuildingManager.h"
#import "YWInspectionEquipmentRecord.h"
#import "YWInspectionMissionManager.h"
#import "YWMission.h"
#import "YWHandler.h"
//#import "YWImageView.h"
#import "YWPhotoView.h"
#import "YWKeepWatchMissionManager.h"
#import "YWRuleTableViewCell.h"
#import "YWPostTroubleInfoCell.h"
#import "YWEquipment.h"
#import "YWEquipmentManager.h"
#import "YWMissionManager.h"
#import "YWDictEquipmentRule.h"
#import "YWMissionRuleResult.h"
#import "YWEquipmentType.h"
#import "YWEquipmentFieldRecord.h"
#import "YWCirculationDetailViewController.h"
#import "YWTroubleMissionModel.h"
#import "YWReportTroubleModel.h"
#import "YWTroubleMissionManager.h"

@interface YWInspecEquipmentRecordDetailTableViewController ()
@property (nonatomic, strong) YWEquipment *equipment;

@property (nonatomic, strong) UIView* headView;
@property (nonatomic, strong) UILabel *buildingLabel;
@property (nonatomic, strong) UIImageView *locationIV;
@property (nonatomic, strong) UILabel *locationLabel;
@property (nonatomic, strong) UIImageView* buildingImageView;
@property (nonatomic, strong) UILabel *dateLabel;

@property (nonatomic, strong) UIView* equipmentView;
@property (nonatomic, strong) UILabel *equipmentNameLabel;
@property (nonatomic, strong) UILabel *ownCodeLabel;

//规则
@property (nonatomic, strong) NSMutableArray* missionRuleResults;
@property (nonatomic, strong) NSString* ruleContent;
//报障信息
@property (nonatomic, strong) NSArray* postTroubleArray;
//设备参数
@property (nonatomic, strong) NSString* fieldRecordContent;

@property (nonatomic, strong) UIView* footView;
@property (nonatomic, strong) UILabel *handlerLabel;
@property (nonatomic, strong) UILabel *resultLabel;
@property (nonatomic, strong) UILabel *noteLabel;
@property (nonatomic, strong) NSMutableArray* recordPictures;
@end

@implementation YWInspecEquipmentRecordDetailTableViewController
- (instancetype)init{
    return [super initWithStyle:UITableViewStyleGrouped];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = NSLocalizedString(@"inspectionRecordsDetail", nil);
    self.view.backgroundColor = [UIColor customBackgroudColor];
    
    self.tableView.backgroundColor = [UIColor customBackgroudColor];
    self.tableView.separatorColor = [UIColor customLineColor];
    self.tableView.sectionFooterHeight = 1.0;
    self.tableView.tableHeaderView = self.headView;
    self.tableView.estimatedRowHeight = 44.0f;
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    
    NSArray *troubleIdArray = [[YWMissionManager shareManager] troubleIdArrayWithDetailUniqueTag:_inspectionEquipmentRecord.detailUniqueTag];
    NSMutableString* troubleIdString = troubleIdArray.count > 0 ? [NSMutableString string] : nil;
    [troubleIdArray enumerateObjectsUsingBlock:^(NSString* _Nonnull idString, NSUInteger idx, BOOL* _Nonnull stop) {
        if (idx!=0) {
            [troubleIdString appendString:@","];
        }
        [troubleIdString appendString:idString];
    }];
    if (troubleIdString.length) {
        YWWeakSelf(weakSelf);
        [[YWTroubleMissionManager shareManager] requestTroubleMissionStatus:troubleIdString withComplete:^(bool success) {
            dispatch_async(dispatch_get_main_queue(), ^{
                weakSelf.postTroubleArray = nil;
                [weakSelf.tableView reloadData];
            });
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setInspectionEquipmentRecord:(YWInspectionEquipmentRecord *)inspectionEquipmentRecord{
    _inspectionEquipmentRecord = inspectionEquipmentRecord;
    if (inspectionEquipmentRecord) {
        _equipment = [[YWEquipmentManager shareManager] equipmentWithId:inspectionEquipmentRecord.equipment.equipmentId];
        //记录的图片
        _recordPictures = [NSMutableArray array];
        if (inspectionEquipmentRecord.pictures.count) {
            [_recordPictures addObjectsFromArray:inspectionEquipmentRecord.pictures];
        }else{
            [_recordPictures addObjectsFromArray:[[YWKeepWatchMissionManager shareManager]recordPictureWithRecordId:inspectionEquipmentRecord.equipmentRecordId recordType:YWPictureRecordTypeInspectionMission]];
        }
    }
}
- (NSString *)fieldRecordContent{
    if (!_fieldRecordContent) {
        //运行参数
        NSArray *fieldRecordArray = [[YWMissionManager shareManager] equipmentFieldRecordsWithUniqueTag:_inspectionEquipmentRecord.equipmentRecordId maintenanceTypeId:YWMaintenanceTypePatrol];
        NSMutableString *contenStr = [NSMutableString string];
        if (fieldRecordArray.count) {
            __block NSString *str = nil;
            [fieldRecordArray enumerateObjectsUsingBlock:^(YWEquipmentFieldRecord*  _Nonnull fieldrecord, NSUInteger idx, BOOL * _Nonnull stop) {
                if (idx != 0) {
                    [contenStr appendString:@"\n"];
                }
                if (fieldrecord.fieldTypeId == YWEquipmentFieldTypeIdDownSelect) {
                    str = [NSString stringWithFormat:@"%@: %@",fieldrecord.fieldName,fieldrecord.fieldOption.fieldOptionText?:NSLocalizedString(@"noContent", nil)];
                }else{
                    str = [NSString stringWithFormat:@"%@: %@",fieldrecord.fieldName,fieldrecord.fieldValue.length?fieldrecord.fieldValue:NSLocalizedString(@"noContent", nil)];
                }
                [contenStr appendString:str];
            }];
        }else{
            [contenStr appendString:NSLocalizedString(@"none", nil)];
        }
        _fieldRecordContent = [NSString stringWithFormat:@"%@",contenStr];
    }
    return _fieldRecordContent;
}

- (NSMutableArray*)missionRuleResults
{
    if (!_missionRuleResults) {
        NSMutableArray* missionRuleResults = [[NSMutableArray alloc] init];
        NSArray* equipmentRules = [[YWEquipmentManager shareManager] rulesWithEquipmentTypeId:_equipment.equipmentTypeId maintenanceTypeId:YWMaintenanceTypePatrol maintenanceCycleId:self.inspectionEquipmentRecord.inspectionMissionId==0 ? YWMissionCycleDay : self.inspectionEquipmentRecord.inspectionMissionId];//临时的显示每日规则
        
        [equipmentRules enumerateObjectsUsingBlock:^(YWDictEquipmentRule* _Nonnull rule, NSUInteger idx, BOOL* _Nonnull stop) {
            YWMissionRuleResult* missionRuleResult = [[YWMissionRuleResult alloc] init];
            missionRuleResult.content = rule.content;
            [missionRuleResults addObject:missionRuleResult];
        }];
        _missionRuleResults = missionRuleResults;
    }
    return _missionRuleResults;
}

- (NSString *)ruleContent{
    if (!_ruleContent) {
        NSString *string = nil;
        BOOL haveRule = self.missionRuleResults.count > 0 ? YES : NO;
        NSMutableString *ruleContent = [NSMutableString string];
        
        for (int i = 0; i < (haveRule ? self.missionRuleResults.count : 1); i++) {
            if (haveRule) {
                YWMissionRuleResult* missionRuleResult = self.missionRuleResults[i];
                string = [NSString stringWithFormat:@"%d.%@", i + 1, missionRuleResult.content];
            }else {
                string = NSLocalizedString(@"none", nil);
            }
            if (i != 0) {
                [ruleContent appendString:@"\n"];
            }
            [ruleContent appendString:string];
        }
        _ruleContent = [NSString stringWithFormat:@"%@",ruleContent];
    }
    return _ruleContent;
}

- (NSArray *)postTroubleArray{
    if (!_postTroubleArray) {
        _postTroubleArray = [[NSArray alloc] initWithArray:[[YWMissionManager shareManager] postTroubleArrayWithDetailUniqueTag:_inspectionEquipmentRecord.detailUniqueTag]];
    }
    return _postTroubleArray;
}

#pragma mark - Table view data source
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return self.equipmentView.frame.size.height;
    }else if (indexPath.section==1) {
        return UITableViewAutomaticDimension;//[YWRuleTableViewCell cellHeightOfRuleContent:self.ruleContent];
    }else if (indexPath.section==2){
        return UITableViewAutomaticDimension;//[YWRuleTableViewCell cellHeightOfRuleContent:self.fieldRecordContent];
    }else if (indexPath.section ==3) {
        return _postTroubleArray.count>0?54:44;
    }else if (indexPath.section ==4) {
        return self.footView.frame.size.height;
    }
    return 0;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 5;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return section == 3 ? (self.postTroubleArray.count?:1) : 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.section == 1 || indexPath.section== 2) {
        YWRuleTableViewCell *cell = [YWRuleTableViewCell cellWithTableView:tableView];
        cell.ruleContent = indexPath.section == 1 ?self.ruleContent:self.fieldRecordContent;
        return cell;
    }else if (indexPath.section==3){
        YWPostTroubleInfoCell *cell = [YWPostTroubleInfoCell cellWithTableView:tableView];
        YWReportTroubleModel *reportTrouble = _postTroubleArray.count>0?_postTroubleArray[indexPath.row]:nil;
        cell.reportTrouble = reportTrouble;
        return cell;
    }else {
        static NSString *identifier = @"YWInspecEquipmentRecordDetailTableViewControllerCellIdentifier";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
        }
        [cell.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
        if (indexPath.section == 0) {
            [cell addSubview:self.equipmentView];
        }else{
            [cell addSubview:self.footView];
        }
        
        return cell;
    }
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section ==3) {
//        YWTroubleMission *troubleMission = _postTroubleArray.count>0?_postTroubleArray[indexPath.row]:nil;
        YWReportTroubleModel * reportTrouble = _postTroubleArray.count>0?_postTroubleArray[indexPath.row]:nil;
        if (reportTrouble) {
            YWCirculationDetailViewController *circulationInfoVC = [[YWCirculationDetailViewController alloc] init];
            circulationInfoVC.isNotShowHandleButton = YES;
            circulationInfoVC.troubleMissionModel = reportTrouble.troubleMission;
            [self.navigationController pushViewController:circulationInfoVC animated:YES];
        }
    }
}
- (UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
{
    static NSString* HeaderIdentifier = @"YWInspecEquipmentRecordDetailTableViewControllerForHeaderInSection";
    UITableViewHeaderFooterView* headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:HeaderIdentifier];
    if (headerView == nil) {
        headerView = [[UITableViewHeaderFooterView alloc] initWithReuseIdentifier:HeaderIdentifier];
        UILabel* label = [[UILabel alloc] init];
        label.textAlignment = NSTextAlignmentLeft;
        label.textColor = [UIColor customTextGrayColor];
        label.tag = 2006;
        label.numberOfLines = 0;
        label.font = KSmallContentFont;
        [headerView addSubview:label];
    }
    NSString *headText = [self titleForHeaderInSection:section];
    UILabel* label = [headerView viewWithTag:2006];
    label.text = headText;
    label.frame = CGRectMake(15, 0, SCREEN_WIDTH - 2 * 15, 35);
    return headerView;
}

-(NSString *)titleForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return NSLocalizedString(@"equipment", nil);//@"设备";
    }else if (section==1){
        return NSLocalizedString(@"inspectionItem", nil);//@"巡查项";
    }else if (section==2){
        return NSLocalizedString(@"equipmentParameter", nil);//@"设备参数";
    }else if (section==3){
        return NSLocalizedString(@"postTroubleInfo", nil);//@"报障信息";
    }else if (section==4){
        return NSLocalizedString(@"recordInfo", nil);//@"记录信息";
    }
    return nil;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 35;
}

- (UIView *)equipmentView{
    if (!_equipmentView) {
        UIView* equipmentView = [[UIView alloc] init];
        equipmentView.backgroundColor = [UIColor whiteColor];
        _equipmentView = equipmentView;
        CGFloat labelW = SCREEN_WIDTH-kMarginW*2;
        //设备名称,类型
        CGFloat equipmentH = [YWCommonTool getHeightOfLabel:self.equipmentNameLabel.text andWidth:labelW andFont:self.equipmentNameLabel.font andMinHeight:kLabelH];
        [self.equipmentNameLabel setFrame:CGRectMake(kMarginW, kGapH, labelW, equipmentH)];
        //自编码
        [self.ownCodeLabel setFrame:CGRectMake(kMarginW, CGRectGetMaxY(self.equipmentNameLabel.frame), labelW, kLabelH)];
        
        [_equipmentView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, equipmentH + kLabelH + kGapH*2)];
    }
    return _equipmentView;
}

- (UIView*)headView
{
    if (!_headView) {
        UIView* headView = [[UIView alloc] init];
        headView.backgroundColor = [UIColor whiteColor];
        _headView = headView;
        
        CGFloat smallIconSize = 17;
        CGFloat dateLabelW = 100;
        
        CGFloat buildingImageSize = 44;
        //楼盘，地址，完成时间
        [self.buildingImageView setFrame:CGRectMake(kMarginW, kGapH, buildingImageSize, buildingImageSize)];
        CGFloat buildingW = SCREEN_WIDTH-kMarginW*4-dateLabelW-CGRectGetMaxX(self.buildingImageView.frame);
        [self.buildingLabel setFrame:CGRectMake(kMarginW+CGRectGetMaxX(self.buildingImageView.frame), kGapH, buildingW, kLabelH)];
        [self.dateLabel setFrame:CGRectMake(SCREEN_WIDTH-dateLabelW-kMarginW, kGapH, dateLabelW, kLabelH)];
        [self.locationIV setFrame:CGRectMake(kMarginW+CGRectGetMaxX(self.buildingImageView.frame), CGRectGetMaxY(self.buildingLabel.frame)+2.5, smallIconSize, smallIconSize)];
        CGFloat locationW = SCREEN_WIDTH-CGRectGetMaxX(self.locationIV.frame)-3-kMarginW;
        CGFloat locationH = [YWCommonTool getHeightOfLabel:self.locationLabel.text andWidth:locationW andFont:self.locationLabel.font andMinHeight:kLabelH];
        [self.locationLabel setFrame:CGRectMake(CGRectGetMaxX(self.locationIV.frame)+3, CGRectGetMaxY(self.buildingLabel.frame), locationW, locationH)];
        
        [_headView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, kGapH*2+kLabelH+locationH)];
    }
    return _headView;
}

- (UIView*)footView
{
    if (!_footView) {
        UIView* footView = [[UIView alloc] init];
        footView.backgroundColor = [UIColor whiteColor];
        _footView = footView;
        
        //结果
        CGFloat resuleSize = 44;
        CGFloat handleW = SCREEN_WIDTH-kMarginW*3-resuleSize;
        [self.handlerLabel setFrame:CGRectMake(kMarginW, kGapH, handleW, kLabelH)];
        [self.resultLabel setFrame:CGRectMake(SCREEN_WIDTH-kMarginW-resuleSize, self.handlerLabel.frame.origin.y, resuleSize, resuleSize)];
        //备注
        CGFloat noteHeight = [YWCommonTool getHeightOfLabel:self.noteLabel.text andWidth:handleW andFont:self.noteLabel.font andMinHeight:kLabelH];
        [self.noteLabel setFrame:CGRectMake(kMarginW,  CGRectGetMaxY(self.handlerLabel.frame), handleW, noteHeight)];
        //照片
        CGFloat imageViewH = 0;
        if (_recordPictures.count > 0) {
            YWPhotoView* imageV = [[YWPhotoView alloc] init];
            imageV.canAddPhoto = NO;
            imageV.photosArray = _recordPictures;
            [imageV setFrame:CGRectMake(0, CGRectGetMaxY(self.noteLabel.frame) + kGapH, imageV.frame.size.width, imageV.frame.size.height)];
            [_footView addSubview:imageV];
            imageViewH = imageV.frame.size.height + kGapH*2;
        }
        [_footView setFrame:CGRectMake(0, 0, SCREEN_WIDTH, kLabelH + noteHeight + imageViewH + kGapH*2)];
    }
    return _footView;
}

-(UILabel *)buildingLabel{
    if (!_buildingLabel) {
        UILabel* buildingLabel = [[UILabel alloc] init];
        buildingLabel.font = [UIFont boldSystemFontOfSize:16];
        YWBuilding* building = [[YWBuildingManager shareManager] buildingWithLocationId:_equipment.locationId];
        NSString* buildingName = building.buildingName.length > 0 ? building.buildingName : NSLocalizedString(@"unknowBuilding", nil);
        buildingLabel.text = buildingName;
        [self.headView addSubview:buildingLabel];
        _buildingLabel = buildingLabel;
    }
    return _buildingLabel;
}
-(UILabel *)dateLabel{
    if (!_dateLabel) {
        UILabel* dateLabel = [[UILabel alloc] init];
        dateLabel.font = [UIFont systemFontOfSize:13];;
        dateLabel.text = [YWCommonTool showTime:_inspectionEquipmentRecord.executeTime / 1000 andFormatter:KTimeFormatShortTimeDate];
        dateLabel.textAlignment = NSTextAlignmentRight;
        dateLabel.textColor = [UIColor customTextGrayColor];
        [self.headView addSubview:dateLabel];
        _dateLabel = dateLabel;
    }
    return _dateLabel;
}
-(UIImageView *)locationIV{
    if (!_locationIV) {
        UIImageView *locationImageV = [[UIImageView alloc]init];
        locationImageV.image = [UIImage imageNamed:@"common_location"];
        [self.headView addSubview:locationImageV];
        _locationIV = locationImageV;
    }
    return _locationIV;
}
-(UILabel *)locationLabel{
    if (!_locationLabel) {
        UILabel* locationLabel = [[UILabel alloc] init];
        locationLabel.font = KSmallContentFont;
        NSString* position = [[YWBuildingManager shareManager] equipmentLocationNobuilding:_equipment];
        locationLabel.text = position.length > 0 ? position : NSLocalizedString(@"noLocation", nil);
        locationLabel.textColor = [UIColor customTextGrayColor];
        locationLabel.numberOfLines = 0;
        [self.headView addSubview:locationLabel];
        _locationLabel = locationLabel;
    }
    return _locationLabel;
}
- (UIImageView*)buildingImageView
{
    if (!_buildingImageView) {
        UIImageView* buildingImageView = [[UIImageView alloc] init];
        buildingImageView.clipsToBounds = YES;
        buildingImageView.layer.cornerRadius = 22.0;
        
        YWBuilding* building = [[YWBuildingManager shareManager] buildingWithLocationId:_equipment.locationId];
        NSString* downloadUrl = [YWCommonTool pictureDownloadUrl:building.surfacePicture];
        [buildingImageView sd_setImageWithURL:[NSURL URLWithString:downloadUrl] placeholderImage:[UIImage imageNamed:@"placeholder_buliding"]];
        [self.headView addSubview:buildingImageView];
        _buildingImageView = buildingImageView;
    }
    return _buildingImageView;
}

-(UILabel *)equipmentNameLabel{
    if (!_equipmentNameLabel) {
        UILabel* equipmentNameLabel = [[UILabel alloc] init];
        equipmentNameLabel.font = kContentFont;
        equipmentNameLabel.numberOfLines = 0;
        NSString *equipmentName = _equipment.equipmentName.length > 0 ? _equipment.equipmentName : NSLocalizedString(@"noEquipment", nil);
        NSString *equTypeName = [[YWEquipmentManager shareManager]equipmentTypeNameWithTypeId:_equipment.equipmentTypeId];
        equTypeName = equTypeName.length > 0 ? equTypeName :NSLocalizedString(@"noEquipmentType", nil);
        NSString *showStr = [NSString stringWithFormat:@"%@  %@",equipmentName,equTypeName];
        NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc]initWithString:showStr];
        NSRange range = NSMakeRange(attriString.length-equTypeName.length, equTypeName.length);
        [attriString addAttribute:NSFontAttributeName value:KSmallContentFont range:range];
        [attriString addAttribute:NSForegroundColorAttributeName value:[UIColor customTextGrayColor]range:range];
        equipmentNameLabel.attributedText = attriString;
        [self.equipmentView addSubview:equipmentNameLabel];
        _equipmentNameLabel = equipmentNameLabel;
    }
    return _equipmentNameLabel;
}
-(UILabel *)ownCodeLabel{
    if (!_ownCodeLabel) {
        UILabel* ownCodeLabel = [[UILabel alloc] init];
        ownCodeLabel.textColor = [UIColor customTextGrayColor];
        ownCodeLabel.font = KSmallContentFont;
        ownCodeLabel.text = _equipment.ownCode.length>0? _equipment.ownCode:NSLocalizedString(@"none", nil);
        [self.equipmentView addSubview:ownCodeLabel];
        _ownCodeLabel = ownCodeLabel;
    }
    return _ownCodeLabel;
}

-(UILabel *)handlerLabel{
    if (!_handlerLabel) {
        UILabel* handlerLabel = [[UILabel alloc] init];
        handlerLabel.font = kContentFont;
        handlerLabel.textColor = [UIColor customTextGrayColor];
        NSString *handlerName = _inspectionEquipmentRecord.executor.userName.length > 0 ? _inspectionEquipmentRecord.executor.userName : NSLocalizedString(@"none", nil);
        [handlerLabel labelText:NSLocalizedString(@"executorFormatter", nil) withAttributedText:handlerName andAttributedColor:[UIColor blackColor]];
        [self.footView addSubview:handlerLabel];
        _handlerLabel = handlerLabel;
    }
    return _handlerLabel;
}
-(UILabel *)resultLabel{
    if (!_resultLabel) {
        UILabel* resultLabel = [[UILabel alloc] init];
        resultLabel.font = kContentFont;
        if (_inspectionEquipmentRecord.status == YWInspectionEquipmentRecordStatusTrouble) {
            resultLabel.text = NSLocalizedString(@"unnormal", nil);//@"故障";
            resultLabel.backgroundColor = [UIColor customRedColor];
        }else{
            resultLabel.text = NSLocalizedString(@"normal", nil);//@"正常";
            resultLabel.backgroundColor = [UIColor customGreenColor];
        }
        resultLabel.textColor = [UIColor whiteColor];
        resultLabel.textAlignment = NSTextAlignmentCenter;
        resultLabel.clipsToBounds = YES;
        resultLabel.layer.cornerRadius = 44/2;
        
        [self.footView addSubview:resultLabel];
        _resultLabel = resultLabel;
    }
    return _resultLabel;
}

- (UILabel*)noteLabel
{
    if (!_noteLabel) {
        UILabel* noteLabel = [[UILabel alloc] init];
        noteLabel.font = kContentFont;
        noteLabel.numberOfLines = 0;
        noteLabel.textColor = [UIColor customTextGrayColor];
        NSString* note = _inspectionEquipmentRecord.note.length > 0 ? _inspectionEquipmentRecord.note : NSLocalizedString(@"noContent", nil);
        //        noteLabel.text = [NSString stringWithFormat:@"备注: %@", note];
        [noteLabel labelText:NSLocalizedString(@"noteFormatter", nil) withAttributedText:note andAttributedColor:[UIColor blackColor]];
        [self.footView addSubview:noteLabel];
        _noteLabel = noteLabel;
    }
    return _noteLabel;
}
@end
